package com.itheima.map;

import java.util.Comparator;
import java.util.TreeMap;

/**
 * @author zhangbaiyan
 * @date 2024-09-12 15:35
 * @description:
 * @version:
 */
public class Test4 {
    public static void main(String[] args) {
        TreeMap<Integer, String> tm =new TreeMap<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2 - o1;
            }
        });

        //2.添加元素
        tm.put(1,"可恰可乐");
        tm.put(2,"康师傅冰红茶");
        tm.put(3, "康师傅density");
        tm.put(4, "九个核桃");
        tm.put(5, "奥里给");


        System.out.println(tm);
    }
}
